<%@page contentType="text/html;charset=utf-8"%>
<%@include file="../../core/common.jsp"%>
<html>
<head>
<title></title>
</head>
<script>
	var khs = $.loadOption('${CTX}/mgt/t/kh/option');
	function kh_(value, row, index) {
		return khs[value];
	}
	var jhs = $.loadOption('${CTX}/mgt/t/jh/option');
	function jh_(value, row, index) {
		return jhs[value];
	}
	var zzs = $.loadOption('${CTX}/mgt/t/zz/option');
	function zz_(value, row, index) {
		return zzs[value];
	}
</script>
<body>
	<div id="tb" class="toolbar">
		<form id="fm">
			<table class="form-layout w80">
				<tr>
					<td>合同编号：</td>
					<td><input name="search_htbh" class="easyui-textbox" /></td>
					<td>合同期起：</td>
					<td><input name="search_begin" class="easyui-datebox" data-options="editable:false" /></td>
					<td>合同期止：</td>
					<td><input name="search_end" class="easyui-datebox" data-options="editable:false" /></td>
				</tr>
				<tr>
					<td>规格型号：</td>
					<td><input name="search_ggxh" class="easyui-combobox" data-options="url:'${CTX}/mgt/sys/dict/value/ph',editable:false,formatter:''" /></td>
					<td>是否完成：</td>
					<td><input name="search_sfwc" class="easyui-combobox" data-options="url:'${CTX}/mgt/sys/dict/option/sfbj'" value="0" /></td>
					<td>需方：</td>
					<td><input name="search_khId" class="easyui-combobox" data-options="url:'${CTX}/mgt/t/kh/option',editable:false,formatter:''" /></td>
				</tr>
			</table>
		</form>
		<div style="float: left;">
			<shiro:hasPermission name="ht:insert">
				<a id="insert" class="form-btn primary">
					<i class="fa fa-plus m-r-5"></i>添加
				</a>
			</shiro:hasPermission>
			<shiro:hasPermission name="ht:update">
				<a id="update" class="form-btn primary">
					<i class="fa fa-pencil-square-o m-r-5"></i>修改
				</a>
			</shiro:hasPermission>
			<shiro:hasPermission name="ht:delete">
				<a id="delete" class="form-btn danger">
					<i class="fa fa-trash-o m-r-5"></i>删除
				</a>
			</shiro:hasPermission>
		</div>
		<div style="float: right;">
			<a id="find" class="form-btn success">
				<i class="fa fa-search m-r-5"></i>查询
			</a>
			<a id="reset" class="form-btn default">
				<i class="fa fa-undo m-r-5"></i>重置
			</a>
		</div>
		<div style="clear: both;"></div>
	</div>
	<table id="dg" class="easyui-datagrid" data-options="url:'${CTX}/mgt/t/ht/find',queryParams:{search_sfwc:'0'},toolbar:'#tb',pagination:true">
		<thead>
			<tr>
				<th data-options="field:'htbh',width:100">合同编号</th>
				<th data-options="field:'htrq',width:100">合同时间</th>
				<th data-options="field:'ggxh',width:100">规格型号</th>
				<th data-options="field:'htzl',width:100">合同重量(T)</th>
				<th data-options="field:'ckzl',width:100">出库重量(T)</th>
				<th data-options="field:'yckzl',width:100">已出库重量(T)</th>
				<th data-options="field:'khId',width:250,formatter:kh_">需方</th>
				<th data-options="field:'jhId',width:250,formatter:jh_">交货方</th>
				<th data-options="field:'zzId',width:250,formatter:zz_">制造方</th>
			</tr>
		</thead>
	</table>
</body>
<script>
	$(function() {
		$('#find').click(function() {
			$('#dg').datagrid('reload', $('#fm').serializeObject());
		});
		$('#reset').click(function() {
			$('#fm').form('reset');
			$('#find').click();
		});
		$('#insert').click(function() {
			$.open({
				title : $(this).html(),
				url : '${CTX}/mgt/t/ht/insert',
				end : function() {
					$('#find').click();
				}
			});
		});
		$('#update').click(function() {
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				$.open({
					title : $(this).html(),
					url : '${CTX}/mgt/t/ht/update?id=' + row.id,
					end : function() {
						$('#find').click();
					}
				});
			} else {
				$.info('请选择合同');
			}
		});
		$('#delete').click(function() {
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				$.confirm('确定删除合同', function() {
					$.mask();
					$.ajax({
						url : '${CTX}/mgt/t/ht/delete',
						data : {
							id : row.id
						},
						success : function(data) {
							$.unmask();
							$.handle(data, function() {
								$('#find').click();
							});
						}
					});
				});
			} else {
				$.info('请选择合同');
			}
		});
	});
</script>
</html>